<?php
/**
 * Created by PhpStorm.
 * User: wangkxin@foxmail.com
 * Date: 2020/9/14
 * Time: 11:17
 */

namespace app\admin\model;
use think\Model;

class Category extends Model
{
    protected $autoWriteTimestamp = true;
    public function add($data)
    {
        $data['status'] = 1;
        // $data['create_time'] = time();
        return $this->save($data);
    }

    #新增栏目时候显示的一级栏目下拉
    public function getNormalFirstCategory()
    {
        $data = [
            'status'=>1,
            'parent_id'=>0,
        ];
        $order=[
            'id'=>'desc'
        ];
        return $this->where($data)
            ->order($order)
            ->select();
    }

    public function getFirstCategorys($parent_Id)
    {
        $data=[
            'parent_id'=>$parent_Id,
            'status'=>['neq',-1]
        ];
        $order=[
            'listorder' => 'ASC',
            'id' => 'ASC',
        ];
        $result = $this->where($data)
            ->order($order)
            ->paginate();
        // echo $this->getLastSql();
        return $result;
    }





}